﻿using MediatR;
using Sale.Api.Application.工单.Command.OpenFare;
using Sale.Domain.工单;
using Sale.ErrorCode;
using Sale.Infrastructure.Interface;
using SqlSugar;

namespace Sale.Api.Application.工单.Handler.OpenFare
{
    public class FanTianOpenFareHandler : IRequestHandler<FanTianOpenFareCommand, ApiResult<List<OpenFareModel>>>
    {
        private readonly ILogger<FanTianOpenFareHandler> logger;
        private readonly IBaseRepository<OpenFareModel> openFareRepo;

        public FanTianOpenFareHandler(ILogger<FanTianOpenFareHandler> logger,IBaseRepository<OpenFareModel> openFareRepo)
        {
            this.logger = logger;
            this.openFareRepo = openFareRepo;
        }
        public Task<ApiResult<List<OpenFareModel>>> Handle(FanTianOpenFareCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<OpenFareModel>> result=new ApiResult<List<OpenFareModel>>();
            var openFare = openFareRepo.GetAllAsync(x=>x.OpenFareId==request.OpenFareId).ToList();
            result.Code = ApiEnum.OK;
            result.Data = openFare;
            result.Msg = "查询成功";
            return Task.FromResult(result);
        }
    }
}
